package cn.sdhuijin.healthexam.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import cn.sdhuijin.healthexam.ExitApplication;
import cn.sdhuijin.healthexam.R;
import cn.sdhuijin.healthexam.control.AbstractControlActivity;
import cn.sdhuijin.healthexam.util.Constants;

/**
 * 新生儿随访第三页
 * 
 * 
 * @author sunping
 */
public class NewChildrenVisitThirdActivity extends AbstractControlActivity
		implements OnClickListener {

	// 创建日期ID
	private String createDate;
	private int[] huanggen = { R.id.check_huanggenbuwei_mb,
			R.id.check_huanggenbuwei_qg, R.id.check_huanggenbuwei_sz,
			R.id.check_huanggenbuwei_shouzu };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_newchildren_visit_third);
		ExitApplication.getInstance().addActivity(this);

		Intent intent = getIntent();
		Bundle bundle = intent.getBundleExtra("bundle");
		if (bundle != null) {
			createDate = bundle.getString("createDate");
		}
		setCurrentEditUserName(createDate);

		addRadioGroupView(R.id.rad_tinglishaixuan, "新生儿听力筛查");
		addRadioGroupView(R.id.rad_jibingshaixuan, "新生儿疾病筛查");
		addEditTextView(R.id.edt_chushengtizhong, "新生儿出生体重");
		addEditTextView(R.id.edt_muqiantizhong, "目前体重");
		addEditTextView(R.id.edt_chushengshengao, "出生身长");
		addRadioGroupView(R.id.rad_weiyangfangshi, "喂养方式");
		addEditTextView(R.id.edt_chinailiang, "吃奶量");
		addEditTextView(R.id.edt_chinaicishu, "吃奶次数");
		addRadioGroupView(R.id.rad_outu, "呕吐");
		addRadioGroupView(R.id.rad_dabian, "大便");
		addEditTextView(R.id.edt_dabiancishu, "大便次数");
		addEditTextView(R.id.edt_tiwen, "体温");
		addEditTextView(R.id.edt_mailv, "脉率");
		addEditTextView(R.id.edt_huxipinlv, "呼吸频率");
		addRadioEditUnionView(new int[] { R.id.edt_mianse_qt }, "面色",
				new String[] { "面色其他" }, R.id.rad_mianse, "其他");
		addCheckBoxView(huanggen, "黄疸部位 ");

		// Properties文件路径
		controlManager.setPropertiesPath(Constants.PROPERTIES_PATH + createDate
				+ ".txt");
		Log.i(NewChildrenVisitSecondActivity.class.getSimpleName(), "文件路径： "
				+ Constants.PROPERTIES_PATH + createDate + ".txt");
		controlManager.toControl();
		setButtonListener(this, R.id.btn_next, R.id.btn_previous);
	}

	/**
	 * 按钮点击处理事件
	 */
	@Override
	public void onClick(View arg0) {
		Intent intent = new Intent();
		Bundle bundle = new Bundle();
		// 获取点击按钮ID
		int id = (Integer) arg0.getId();
		switch (id) {
		case R.id.btn_next:
			controlManager.toProperties();
			intent.setClass(this, NewChildrenVisitForthActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			this.finish();
			break;
		case R.id.btn_previous:
			controlManager.toProperties();
			intent.setClass(this, NewChildrenVisitSecondActivity.class);
			bundle.putString("createDate", createDate);
			intent.putExtra("bundle", bundle);
			startActivity(intent);
			this.finish();
			break;
		default:
			break;
		}
	}

}
